<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i> 任务调度</el-breadcrumb-item>
                <el-breadcrumb-item>调度任务</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-row>
                <el-col :span="1">
                    <el-button type="primary" @click="openNew">更新</el-button>
                </el-col>
                <el-col :span="2">
                    <span>监控内容：</span>
                </el-col>   
                <el-col :span="3">
                    <el-input v-model="listKey"></el-input>
                </el-col> 
                <el-col :span="2">
                    <span>类型：</span>
                </el-col>   
                <el-col :span="3">
                    <el-select placeholder="请选择" v-model="listType" clearable>
                        <el-option
                            v-for="item in sqlTypeValues"
                            :key="item.typeId"
                            :label="item.name"
                            :value="item.typeId"
                        ></el-option>
                    </el-select>
                </el-col>  
                <el-col :span="2">
                    <span>数据源：</span>
                </el-col>   
                <el-col :span="3">
                    <el-select placeholder="请选择" v-model="connectId2" clearable>
                        <el-option
                            v-for="item in sourceList"
                            :key="item.createTime"
                            :label="item.connectName"
                            :value="item.rowId"
                        ></el-option>
                    </el-select>
                </el-col>
                <el-col :span="2">
                    <span>状态：</span>
                </el-col>
                <el-col :span="3">
                    <el-select placeholder="请选择" v-model="listStatus" clearable>
                        <el-option
                            v-for="item in taskStatus"
                            :key = "item.value" 
                            :label = "item.title"
                            :value = "item.value"
                        ></el-option>
                    </el-select>
                </el-col>
                <el-col :span="1" class="ml10">
                    <el-button @click="findInList">查找</el-button>
                </el-col>
                <a :href="exportUrl" class="r exportLink"  target="_blank" :style="{background:maincolor||'#5a6775'}">导出</a>
            </el-row>
            <el-table
                ref="multipleTable"
                :data="dispatchTaskList"
                border
                v-loading="loading"
                style="width: 100%; margin-top:20px">
                <el-table-column
                    type="index"
                    label="序号"
                    width="55">
                </el-table-column>
                <el-table-column
                    prop="title"
                    label="监控内容">
                </el-table-column>
                <el-table-column
                    prop="sqlTypeName"
                    label="类型"
                    width="55">
                </el-table-column>
                <el-table-column
                    prop="scheduleTitle"
                    label="任务调度">
                </el-table-column>
                <el-table-column
                    prop="timeInfo"
                    width="80"
                    label="调度时间">
                </el-table-column>
                <el-table-column
                    prop="nextExecTime"
                    label="下次运行时间">
                </el-table-column>
                <el-table-column
                    prop="lastExecTime"
                    label="最后一次运行时间">
                </el-table-column>
                <el-table-column
                    prop="exceptionCount"
                    label="最后一次数据数">
                </el-table-column>
                <el-table-column
                    prop="sqlTime"
                    width="80"
                    label="耗时(秒)">
                </el-table-column>
                <el-table-column
                    prop="statusName"
                    width="80"
                    label="状态">
                </el-table-column>
                <el-table-column
                    label="操作">
                    <template slot-scope="scope">
                        <a @click="updateStatus(scope.row)" v-if="scope.row.scheduleId !== null" class="mr15">{{scope.row.status == 1?"开启":"暂挂"}}</a>
                        <a @click="delRow(scope.row.rowId)" class="mr15">删除</a>
                        <a @click="handleLog(scope.row.rowId)">日志</a>
                    </template>
                </el-table-column>
            </el-table>
            <div class="page_container">
                <el-pagination
                    @current-change="handleCurrentChange"
                    :current-page.sync="currentPage"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="threadNum"
                    layout="total, prev, pager, next, jumper"
                    :total="totalNum">
                </el-pagination>
            </div>
        </div>
        <div>
            <el-dialog
                title="更新调度任务"
                :visible.sync="dialogVisible"
                width="60%"
            >
                <el-row class="mt20">
                    <el-col :span="3"><span><span class="red">*</span>调度方式：</span></el-col>
                    <el-col :span="4">
                        <el-select v-model="scheduleId" placeholder="请选择" clearable>
                            <el-option
                                v-for="item in dispatchMenu"
                                :key="item.rowId"
                                :label="item.title"
                                :value="item.rowId">
                            </el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="2"><span>日期：</span></el-col>
                    <el-col :span="6">
                        <el-date-picker
                                    v-model="dateInfo"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="选择日期">
                                </el-date-picker>
                    </el-col>
                    <el-col :span="2"><span>时间：</span></el-col>
                    <el-col :span="4">
                        <el-time-select
                                    v-model="timeInfo"
                                    :picker-options="{
                                        start: '0:00',
                                        step: '00:01',
                                        end: '23:59'
                                    }"
                                    editable
                                    clearable
                                    placeholder="选择时间">
                                </el-time-select>
                    </el-col>
                </el-row>
                <div v-if="showSelectRows.length !==0 ">
                    <el-table
                        :data="showSelectRows.slice((currentPage4-1)*threadNum,currentPage4*threadNum)"
                        border
                        style="width: 100%; margin-top:20px"
                    >
                        <el-table-column
                            type="index"
                            label="序号"
                            width="50">
                        </el-table-column>
                        <el-table-column
                            prop="dashBoardSqlEntity.title"
                            label="监控内容"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="connectionInfoEntity.connectName"
                            label="数据源"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="dashBoardSqlEntity.sqlTypeName"
                            label="类别">
                        </el-table-column>
                </el-table>
                <div class="page_container">
                    <el-pagination
                        @current-change="handleCurrentChange4"
                        :current-page.sync="currentPage4"
                        :page-sizes="[5, 10, 15, 20]"
                        :page-size="threadNum"
                        layout="total, prev, pager, next, jumper"
                        :total="showSelectRows.length">
                    </el-pagination>
                </div>
                </div>
                <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="chooseTable">选 择</el-button>
                    <el-button type="primary" @click="addNew" :loading="btnloading">更 新</el-button>
                </span>
            </el-dialog>
            <el-dialog
                :visible.sync="dialogVisible2"
                width="50%"
            >
                <el-row>
                    <el-col :span="3"><span>监控内容：</span></el-col>
                    <el-col :span="4">
                        <el-input placeholder="库存物料属性" v-model="searchKey1"></el-input>
                    </el-col>
                    <el-col :span="3"><span>数据源：</span></el-col>
                    <el-col :span="4">
                        <el-select placeholder="请选择" v-model="connectId" clearable>
                        <el-option
                            v-for="item in sourceList"
                            :key="item.createTime"
                            :label="item.connectName"
                            :value="item.rowId"
                        ></el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="2"><span>类别：</span></el-col>
                    <el-col :span="4">
                        <el-select placeholder="请选择" v-model="sqlType" clearable>
                            <el-option
                                v-for="item in sqlTypeValues"
                                :key="item.typeId"
                                :label="item.name"
                                :value="item.typeId"
                            ></el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="2" :offset="1"><el-button type="primary" @click="handleCheck">查找</el-button></el-col>
                </el-row>
                <el-table
                    :data="sqlList.slice((currentPage2-1)*threadNum,currentPage2*threadNum)"
                    border
                    ref="multipleTable"
                    v-loading="loading2"
                    style="width: 100%; margin-top:20px"
                    @select="handleSelect"
                    @select-all="handleSelect"
                >
                <el-table-column
                    type="selection"
                    width="50"
                    >
                </el-table-column>
                <el-table-column
                    type="index"
                    label="序号"
                    width="50">
                </el-table-column>
                <el-table-column
                    prop="dashBoardSqlEntity.title"
                    label="监控内容"
                    width="180">
                </el-table-column>
                <el-table-column
                    prop="connectionInfoEntity.connectName"
                    label="数据源"
                    width="180">
                </el-table-column>
                <el-table-column
                    prop="dashBoardSqlEntity.sqlTypeName"
                    label="类型">
                </el-table-column>
            </el-table>
            <div class="page_container">
                <el-pagination
                    @current-change="handleCurrentChange2"
                    :current-page.sync="currentPage2"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="threadNum"
                    layout="total, prev, pager, next, jumper"
                    :total="totalNum2">
                </el-pagination>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelChoose">取 消</el-button>
                <el-button type="primary" @click="getSelectRows">确 定</el-button>
            </span>
            </el-dialog>
            <el-dialog
                :visible.sync="dialogVisible3"
                width="60%"
            >
                <el-row>
                    <el-col :span="4">
                        <el-checkbox v-model="errorLog" @change="triggerError" style="font-size:14px; font-weight:bold">错误日志</el-checkbox>
                    </el-col>
                </el-row>
                <el-table
                    :data="logList"
                    border
                    v-loading="loading3"
                    row-class-name="tableRow"
                    style="width: 100%; margin-top:20px"
                >
                <el-table-column
                    type="index"
                    label="序号"
                    width="50">
                </el-table-column>
                <el-table-column
                    prop="remark"
                    label="异常信息"
                >
                </el-table-column>
                <el-table-column
                    prop="createTime"
                    label="执行时间">
                </el-table-column>
                <el-table-column
                    prop="exceptionCount"
                    label="数量"
                >
                </el-table-column>
                <el-table-column
                    prop="sqlTime"
                    label="耗时(s)"
                >
                </el-table-column>
                <el-table-column
                    label="操作">
                    <template slot-scope="scope">
                        <a @click="checkKK(scope.row)" class="mr15">即时通讯</a>
                        <a @click="checkEmail(scope.row)" class="mr15">邮箱</a>
                    </template>
                </el-table-column>
            </el-table>
            <div class="page_container">
                <el-pagination
                    @current-change="handleCurrentChange3"
                    :current-page.sync="currentPage3"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="threadNum"
                    layout="total, prev, pager, next, jumper"
                    :total="logNum">
                </el-pagination>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible3 = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible3 = false">确 定</el-button>
            </span>
            </el-dialog>
            <el-dialog
                :visible.sync="dialogVisiblekk"
                width="80%"
            >
                <el-table
                    :data="kkList"
                    border
                    v-loading="loadingkk"
                    :cell-style="cellStyle"
                    :cell-class-name="cellClassName"
                >
                <el-table-column
                    type="index"
                    label="序号"
                    width="50">
                </el-table-column>
                <el-table-column
                    prop="toSendAddress"
                    label="接收地址"
                    width="150"
                >
                </el-table-column>
                <el-table-column
                    prop="emailContent"
                    label="发送内容"
                >
                </el-table-column>
                <el-table-column
                    prop="status"
                    label="状态"
                    width="80">
                </el-table-column>
                <el-table-column
                    prop="updateTime"
                    label="发送时间"
                    width="140"
                >
                </el-table-column>
            </el-table>
            <div class="page_container">
                <el-pagination
                    @current-change="handleCurrentChangekk"
                    :current-page.sync="currentPagekk"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="threadNum"
                    layout="total, prev, pager, next, jumper"
                    :total="kkNum">
                </el-pagination>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisiblekk = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisiblekk = false">确 定</el-button>
            </span>
            </el-dialog>
            <el-dialog
                :visible.sync="dialogVisibleEmail"
                width="80%"
            >
                <el-table
                    :data="emailList"
                    border
                    v-loading="loadingEmail"
                    :cell-style="cellStyle"
                    :cell-class-name="cellClassName"
                >
                <el-table-column
                    type="index"
                    label="序号"
                    width="50">
                </el-table-column>
                <el-table-column
                    prop="toSendAddress"
                    label="接收地址"
                    width="150"
                >
                </el-table-column>
                <el-table-column
                    prop="emailContent"
                    label="发送内容"
                >
                </el-table-column>
                <el-table-column
                    prop="status"
                    label="状态"
                    width="80">
                </el-table-column>
                <el-table-column
                    prop="updateTime"
                    label="发送时间"
                    width="140"
                >
                </el-table-column>
            </el-table>
            <div class="page_container">
                <el-pagination
                    @current-change="handleCurrentChangeEmail"
                    :current-page.sync="currentPageEmail"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="threadNum"
                    layout="total, prev, pager, next, jumper"
                    :total="emailNum">
                </el-pagination>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisibleEmail = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisibleEmail = false">确 定</el-button>
            </span>
            </el-dialog>
        </div>
    </div>
</template>
<script>
import { mapState } from 'vuex'
import utils from '../../utils/index.js'
export default {
    data() {
        return {
            exportUrl:"",
            loading: false,
            loading2: false,
            loading3: false,
            loadingkk: false,
            loadingEmail: false,
            currentPage:1,
            currentPage2:1,
            currentPage3:1,
            currentPage4:1,
            currentPagekk: 1,
            currentPageEmail: 1,
            dialogVisible: false,
            dialogVisible2: false,
            dialogVisible3: false,
            dialogVisible4: false,
            dialogVisiblekk: false,
            dialogVisibleEmail: false,
            isFit: true,
            rowIds: [],
            connectId:"",
            connectId2:"",
            searchKey1:"",
            sqlType:"",
            scheduleId:"",
            dateInfo:"",
            timeInfo:"",
            listKey:"",
            listType:"",
            listStatus:"",
            threadNum: parseInt(localStorage.getItem('pagesize')),
            rowId:"",
            selectRows: [],
            showSelectRows: [],
            errorLog: false,
            btnloading: false,
            currentKKId: "",
            currentEmailId:""
        }
    },
    computed: mapState({
        msg: state => state.task.msg,
        flag: state => state.task.flag,
        msg2: state => state.sql.msg,
        dispatchMenu: state => state.sql.dispatchMenu,
        sourceList: state => state.sql.sourceList,
        dispatchTaskList(state) {
            let arr = [];
            state.task.dispatchTaskList.map((item) => {
                item.lastExecTime = item.lastExecTime ? this.formatDate(item.lastExecTime):'';
                item.nextExecTime = item.nextExecTime ? this.formatDate(item.nextExecTime):'';
                arr.push(item);
            });
            return arr;
        },
        totalNum: state => state.task.totleNum2,
        totalNum2: state => state.sql.totleNum2,
        sqlTypeValues: state => state.system.sqlType,
        taskStatus: state => state.system.taskStatus,
        sqlList: state => state.sql.sqlList,
        maincolor: state => state.system.colors,
        logList(state){
            let arr = [];
            state.task.logList.map((item) => {
                item.createTime = item.createTime ? this.formatDate(item.createTime):'';
                arr.push(item);
            });
            return arr;
        },
        logNum: state => state.task.logNum,
        kkList(state) {
            let arr = [];
            state.task.kkList.map((item) => {
                item.status = typeof(item.status) == 'number' ? this.getStatus(item.status):"";
                item.updateTime = item.updateTime ? this.formatDate(item.updateTime):'';
                arr.push(item);
            })
            return arr;
        },
        kkNum: state => state.task.kkNum,
        emailList(state) {
            let arr = [];
            state.task.emailList.map((item) => {
                item.status = typeof(item.status) == 'number' ? this.getStatus(item.status):"";
                item.updateTime = item.updateTime ? this.formatDate(item.updateTime):'';
                arr.push(item);
            })
            return arr;
        },
        emailNum: state => state.task.emailNum
    }),
    mounted() {
        if(localStorage.getItem('pageType') == 0) {
            this.$router.push({ path:'/user' });
        }
        this.getType();
        this.getSourceList();
        this.getTaskList();
        this.exportUrl = utils.apiUrl + '/export/task?sessionId=' + localStorage.getItem('sessionId') + '&searchKey=' + this.listKey + '&taskType=0&status=' + this.listStatus + '&connectId=' + this.connectId2;
    },
    methods:{
        cellStyle({row, column, rowIndex, columnIndex}) {
            if(columnIndex == 2) {
                return 'height: auto; white-space:normal'
            }else{
                return ''
            }
        },
        cellClassName({row,column,rowIndex,columnIndex}){
            return 'autoWrap'
        },
        checkKK(row) {
            this.loadingkk = true;
            this.currentKKId = row.rowId;
            this.dialogVisiblekk = true;
            this.$store.dispatch("getKKList",{
                pageNo: 1,
                pageSize: this.threadNum,
                logId: row.rowId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                if(this.msg !== '成功') {
                    this.loadingkk = false;
                    this.$message(this.msg)
                }else{
                    this.loadingkk = false;
                }
            })
        },
        checkEmail(row) {
            this.loadingEmail = true;
            this.currentEmailId = row.rowId;
            this.dialogVisibleEmail = true;
            this.$store.dispatch("getEmailList",{
                pageNo: 1,
                pageSize: this.threadNum,
                logId: row.rowId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                if(this.msg !== '成功') {
                    this.loadingEmail = false;
                    this.$message(this.msg)
                }else{
                    this.loadingEmail = false;
                }
            })
        },
        getColor() {
            this.$store.dispatch("getColor", {
                sessionId: localStorage.getItem('sessionId')
            })
        },
        formatDate(d) {
            if (!!window.ActiveXObject || "ActiveXObject" in window) {
                return new Date(parseInt(d)).toLocaleString({hour12:false});
            }else if(navigator.userAgent.indexOf('Edge') > -1) {
                return new Date(parseInt(d)).toLocaleString({hour12:false});
            }else{
                return new Date(parseInt(d)).toLocaleString('chinese',{hour12:false});
            }
        },
        getStatus(num) {
            let arr = ["等候发送","成功","失败","邮箱不存在","未开启"];
            return arr[num]
        },
        getType() {
            this.$store.dispatch("getTypes",{
                sessionId: localStorage.getItem('sessionId')
            })
        },
        handleCurrentChange(val) {
            this.getTaskList(val);
        },
        handleCurrentChange2(val) {
            this.currentPage2 = val;
            if(this.selectRows.length) {
                for(let key of this.sqlList) {
                    if(this.selectRows.indexOf(key.dashBoardSqlEntity.rowId) > -1) {
                        this.$refs.multipleTable.toggleRowSelection(key)
                    }
                }
            }
        },
        handleCurrentChange4(val) {
            this.currentPage4 = val;
        },
        handleCurrentChange3(val) {
            this.loading3 = true;
            this.$store.dispatch('getErrorLog',{
                error: this.errorLog,
                pageNo:val,
                pageSize: this.threadNum,
                rowId: this.rowId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.loading3 = false;
            })
        },
        handleCurrentChangekk(val) {
            this.loadingkk = true;
            this.$store.dispatch("getKKList",{
                pageNo: val,
                pageSize: this.threadNum,
                logId: this.currentKKId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                if(this.msg !== '成功') {
                    this.loadingkk = false;
                    this.$message(this.msg)
                }else{
                    this.loadingkk = false;
                }
            })
        },
        handleCurrentChangeEmail(val) {
            this.loadingEmail = true;
            this.$store.dispatch("getEmailList",{
                pageNo: val,
                pageSize: this.threadNum,
                logId: this.currentEmailId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                if(this.msg !== '成功') {
                    this.loadingEmail = false;
                    this.$message(this.msg)
                }else{
                    this.loadingEmail = false;
                }
            })
        },
        getSelectRows() {
            this.showSelectRows = [];
            this.dialogVisible2 = false;
            for(let i = 0; i < this.selectRows.length; i++) {
                this.sqlList.map((item) => {
                    if(item.dashBoardSqlEntity.rowId == this.selectRows[i]) {
                        this.showSelectRows.push(item);
                    }
                })
            }
        },
        getDispatchMenu() {
            this.$store.dispatch("getDispatchMenu", {
                pageNo: 1,
                pageSize: 99,
                sessionId: localStorage.getItem("sessionId")
            });
        },
        openNew() {
            this.showSelectRows = [];
            this.getDispatchMenu();
            this.dialogVisible = true;
        },
        getSourceList() {
            this.$store.dispatch("getSourceList", {
                pageNo: 1,
                pageSize: 99,
                sessionId: localStorage.getItem("sessionId")
            });
        },
        getSqlList(page,key,id) {
            this.loading2 = true;
            this.$store.dispatch('getSqlList', {
                connectId:id || null,
                searchKey:key || null,
                pageNo:page || 1,
                pageSize: 999,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.loading2 = false;
            })
        },
        chooseTable() {
            this.showSelectRows = [];
            this.selectRows = [];
            if(this.sqlList.length == 0) {
                this.getSqlList();
            }
            this.dialogVisible2 = true;
        },
        handleCheck() {
            let searchKey = this.searchKey1 || null;
            let connectId = this.connectId || null;
            this.getSqlList(1, searchKey, connectId);
        },
        handleSelect(val) {
            this.addSelect(val);
            this.rowIds = val.map((item) => {
                return item.dashBoardSqlEntity.rowId
            });
            //this.selectRows = [].concat(val);
        },
        handleSelectAll(val) {
            let pagesize = localStorage.getItem('pagesize');
            if(val.length < this.sqlList.length) {
                this.addSelect(this.sqlList);
                this.rowIds = this.sqlList.map((item) => {
                    return item.dashBoardSqlEntity.rowId
                });
            }else if(val.length < pagesize || val.length > pagesize){
                let voidList = [];
                this.addSelect(voidList);
            }
        },
        addSelect(val) {
            let arr = [];
            val.map((item) => {
                arr.push(item.dashBoardSqlEntity.rowId)
            });
            if(val.length < this.selectRows.length) {
                this.selectRows = arr;
                // for(let i = 0; i < this.selectRows.length; i++) {
                //     if(arr.indexOf(this.selectRows[i]) == -1) {
                //         this.selectRows.splice(i,1);
                //     }
                // }
            }else{
                for(let key of val) {
                    if(!(this.selectRows.indexOf(key.dashBoardSqlEntity.rowId) > -1)) {
                        this.selectRows.push(key.dashBoardSqlEntity.rowId)
                    }
                }
            }
        },
        cancelChoose() {
            this.dialogVisible2 = false;
            this.rowIds = [];
        },
        addNew() {
            this.btnloading = true;
            this.$store.dispatch("addNewDispatch",{
                dateInfo: this.dateInfo,
                parentIds: this.rowIds.join(","),
                scheduleId: this.scheduleId,
                timeInfo: this.timeInfo,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                if(this.flag == 0) {
                    this.btnloading = false;
                    this.$message(this.msg);
                    this.dialogVisible = false;
                    this.getTaskList();
                }else{
                    this.btnloading = false;
                    this.$message(this.msg);
                }
                
            })
        },
        getTaskList(page, key, status, taskType, connectId) {
            this.loading = true;
            this.$store.dispatch("taskDispatchList",{
                pageNo: page || 1,
                pageSize: this.threadNum,
                searchKey: key || null,
                status: status || null,
                taskType: taskType || null,
                connectId: connectId || null,
                sessionid: localStorage.getItem("sessionId")
            }).then(() => {
                if(this.msg !== '成功') {
                    this.loading = false;
                    this.$message(this.msg)
                }else{
                    this.loading = false;
                }
            })
        },
        findInList() {
            this.getTaskList(1, this.listKey, this.listStatus.toString(), this.listType.toString(), this.connectId2);
            this.exportUrl = utils.apiUrl + '/export/task?sessionId=' + localStorage.getItem('sessionId') + '&searchKey=' + this.listKey + '&taskType=0&status=' + this.listStatus + '&connectId=' + this.connectId2;
        },
        updateStatus(row) {
            var status;
            if(row.status == 1) {
                status = 0
            }else{
                status = 1
            }
            this.$store.dispatch('updateDispatchStatus',{
                rowId: row.rowId,
                status: status,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.$message(this.msg);
                this.getTaskList(this.currentPage);
            })
        },
        delRow(id) {
            this.$confirm('确定删除？','提示',{
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                   this.$store.dispatch('delSql',{
                        rowId: id,
                        sessionId: localStorage.getItem('sessionId')
                    }).then(() => {
                        this.$message(this.msg2);
                        this.getTaskList();
                    })
                }).catch((err) => {
                    console.log(err);
                })
        },
        handleLog(id) {
            this.rowId = id;
            this.dialogVisible3 = true;
            this.loading3 = true;
            this.$store.dispatch('getErrorLog',{
                error: this.errorLog,
                pageNo:1,
                pageSize: this.threadNum,
                rowId: id,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.loading3 = false;
            })
        },
        triggerError(val) {
            this.loading3 = true;
            this.$store.dispatch('getErrorLog',{
                error: this.errorLog,
                pageNo:1,
                pageSize: this.threadNum,
                rowId: this.rowId,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.loading3 = false;
            })
        }
    }
}
</script>
<style>
.autoWrap{
    white-space: normal;
}
.autoWrap .cell{
    white-space: normal;
    height: auto;
}
</style>

<style scoped>
.el-table .cell{
    height: auto
}
.el-table th>.cell{
    height: 20px;
}
.el-button+.el-button{
    margin-left:0;
}
.tableRow td .cell{
    height: auto;
}

</style>


